package pl.edu.agh.ki.neuralnetwork.neurons;

public class ThresholdNeuron extends AbstractNeuron {

    /**
     * Sets explicitly threshold which is -bias
     * @param threshold
     */
    public ThresholdNeuron(double threshold) {
        this.setBias(-threshold);
    }

    @Override
    public void compute() {
        double sum = 0.0;
        for (Neuron neuron : inputs.keySet()) {
            sum += neuron.getOutput() * inputs.get(neuron);
        }
        if (bias != null)
            sum += bias;
        if( sum > 0.0 )
            this.output = 1.0;
        else
        	this.output = 0.0;
    }

	public boolean isBias() {
		// TODO Auto-generated method stub
		return false;
	}

}